﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using DAL;
using Common;

namespace BLL
{
    public class SystemParameterBLL
    {
        private SystemParameterDAL dal = new SystemParameterDAL();
        /// <summary>
        /// 获取一条数据
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public SystemParameter GetModel(string type)
        {
            return dal.GetModel(type);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ReturnMessages Update(SystemParameter model)
        {
            ReturnMessages rm = new ReturnMessages();
            try
            {
                if (string.IsNullOrWhiteSpace(model.Value))
                {
                    rm.code = 400;
                    rm.msg = "请输入内容！";
                    return rm;
                }
                int count = dal.Update(model);
                if (count > 0)
                {
                    rm.code = 200;
                    rm.msg = "保存成功";
                }
                else
                {
                    rm.code = 400;
                    rm.msg = "保存失败,影响行数为0";
                }
            }
            catch (Exception ex)
            {
                rm.code = 500;
                rm.msg = "服务器错误！";
                LogHelper.Error(this.GetType().FullName, ex.ToString());
            }
            return rm;

        }

    }
}
